<template>
	<view class="p-t-20">
		<view class="font-32 font-weight m-l-30">请选择注销账号原因</view>
		<view class="font-24 grey m-l-30 m-t-10">账号注销后将清空所有个人资料及匹配信息，请谨慎操作</view>

		<view v-for="(item,index) in editList" :key="index" class="modelBox flex_b" @click="causeFn(item)"
			style="border-radius: 10rpx;">
			<view class="">{{item.remark}}</view>
			<view class="iconfont icon-31xuanzhong f-t" v-if="cause==item.id"></view>
			<view class="iconfont icon-yuanxingweixuanzhong grey" v-else></view>
		</view>

		<view class="bomPosition">
			<button type="primary" @click="preserve">提交</button>
		</view>

		<uv-toast ref="toast"></uv-toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cause: '',
				editList: [

				]
			};
		},
		onLoad() {
			this.offremark()
		},
		methods: {
			preserve() {
				if (!this.cause) {
					uni.showToast({
						title: '请选择原因',
						icon: 'error'
					})
					return
				}
				uni.showModal({
					title: '提示',
					content: '确认要注销吗？',
					success: res => {
						if (res.confirm) {
							this.$api.sendRequest({
								url: '/api/User/useroff',
								data: {
									remark_id: this.cause
								},
								success: res => {
									if (res.code == 1) {
										uni.removeStorage({
											key: 'token',
											success: res => {
												this.$refs.toast.show({
													type: 'default',
													message: '注销成功',
													duration: 1500
												})
												setTimeout(() => {
													uni.redirectTo({
														url: '/pages/login/login'
													})
												}, 1500)
											}
										});


									} else {
										this.$refs.toast.show({
											type: 'default',
											message: res.msg,
											duration: 1500
										})
									}

								}

							})
						} else if (res.cancel) {

						}
					}
				});

			},
			// 获取注销原因 
			offremark() {
				this.$api.sendRequest({
					url: '/api/Index/offremark',
					data: {},
					success: res => {
						this.editList = res.data
					}
				})
			},
			causeFn(item) {
				this.cause = item.id
			}
		}
	}
</script>

<style lang="scss">

</style>
